package com.wanmait.recycle.job;

import javax.annotation.Resource;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.wanmait.recycle.service.ArticleService;

@Component
public class RedisPraiseArticleJob {

	@Resource
	private ArticleService articleService;
	
	/*同步消息到数据库，点赞和取消点赞*/
	@Scheduled(cron="0 0/5 * * * ?")
	public void processQueue() {
		
		//同步点赞
		articleService.processPraiseQueue();
		//同步收藏
		articleService.processCollectQueue();
		
	}
	
	//同步点赞数量
	@Scheduled(cron="0 0/5 * * * ?")
	public void processCount()
	{
		//首先读取Set<Integer> getUpdate() 获得本日哪些被操作（点赞 取消点赞)
		//循环 userLike:1:count 读取点赞数量 批量更新question
	
		articleService.processPraiseCount();
		//同步收藏数量
		articleService.processCollectCount();
		
	}
	
	//同步浏览次数
	@Scheduled(cron="0 0/5 * * * ?")
	public void processArticleViewCount() {
		articleService.processArticleViewCount();
	}
	
	
	
	
	
	
}
